<?php
/**
 * GeoContexter
 * @link http://code.google.com/p/geocontexter/
 * @package GeoContexter
 */

/**
 * spatial search for record items
 *
 * @package GeoContexter
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
 * @author Armand Turpel <geocontexter@gmail.com>
 * @version $Rev: 153 $ / $LastChangedDate: 2010-02-18 17:21:41 +0100 (jeu., 18 févr. 2010) $ / $LastChangedBy: armand.turpel $
 */

namespace Gospecies\Controller;

use Zend\View\Model\ViewModel;
use Gospecies\Controller\AbstractIdentityJsonController;
use Zend\View\Model\JsonModel;

class AjaxGetProjectAttributesJsonController extends AbstractIdentityJsonController
{

    /**
     */
    public function indexAction()
    {
        try {

            $id_group = $this->request->getPost()->id_group;

            $AttributeGetGroupAttributes = $this->CoreModel('AttributeGetGroupAttributes');

            $params  = array('id_group'  => $id_group,
                             'order'     => array('attribute_order' => 'asc'));

            $atttributes                 = $AttributeGetGroupAttributes->run( $params );

            if ($atttributes instanceof \Core\Library\Exception) {
                return new JsonModel(array('error' => $atttributes->getMessage()));
            }

            return new JsonModel($atttributes);

          } catch (\Exception $e) {

            $this->default_error = "Error\n File: " . __file__ . "\nLine: " . __line__ . "\nError: " . $e->getMessage();

            return new JsonModel(array('error' => $this->default_error));

         }
    }
}

